package cn.com.lookang.robot.fnlp;

import org.fnlp.nlp.cn.ner.TimeNormalizer;
import org.fnlp.nlp.cn.ner.TimeUnit;
import org.springframework.core.io.ClassPathResource;

import java.io.IOException;
import java.util.Date;

/**
 * @author liulekang
 * @date 2020/7/25
 */
public class Fnlp {

    private static TimeNormalizer normalizer;

    static {
        ClassPathResource classPathResource = new ClassPathResource("models\\time.m");
        try {
            String path = classPathResource.getURL().getPath();
            normalizer = new TimeNormalizer(path);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Date parseDate(String str){
        System.out.println("parse str = "+str);
        TimeUnit[] timeUnits = normalizer.parse(str);
        System.out.println(timeUnits);
        return timeUnits[0].getTime();
    }
}
